package com.amigo.online.provider.user.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.param.result.BlackUserInfo;
import com.amigo.online.provider.user.service.BlackService;

/**
 * 黑名单相关
 *
 * @author amigo
 */
@RestController
@RequestMapping(value = "/black", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class BlackController extends BaseController {

    @Autowired
    private BlackService blackService;


    /**
     * 拉黑某人
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/black/{userId}", method = RequestMethod.GET)
    public ResponseEntity<Response> blackUserById(@PathVariable Long userId) {
        Boolean suc = blackService.blackUser(userId);
        return success(suc);
    }

    /**
     * 从黑名单移除某人
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/cancelBlack/{userId}", method = RequestMethod.GET)
    public ResponseEntity<Response> cancelBlackById(@PathVariable Long userId) {
        Boolean suc = blackService.cancelBlackUser(userId);
        return success(suc);
    }


    /**
     * 对方有没有把我拉黑
     */
    @RequestMapping(value = "/isBlack/{userId}", method = RequestMethod.GET)
    public ResponseEntity<Response> isBlack(@PathVariable Long userId) {
        Boolean suc = blackService.sufferBlack(userId);
        return success(suc);
    }


    /**
     * 获得黑名单列表
     *
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/getBlackList/{page}/{size}", method = RequestMethod.GET)
    public ResponseEntity<Response> getBlackList(@PathVariable Integer page, @PathVariable Integer size) {
        List<BlackUserInfo> list = blackService.getBlackList(page, size);
        return success(list);
    }

}
